pub fn odd_fibnacci_sum(threshold: u32) -> u32 {
    if threshold < 2 {
        return 0;
    }

    let (mut a, mut b) = (1, 1);
    let mut last_c = a + b;
    let mut sum = 2;

    while b < threshold {
        (a, b) = (b, last_c);
        fib_move(&mut a, &mut b);
        fib_move(&mut a, &mut b);
        last_c = a + b;
        sum += last_c;
    }

    sum -= b;
    if threshold <= a {
        sum -= a;
    }
    sum
}

fn fib_move(a: &mut u32, b: &mut u32) {
    (*a, *b) = (*b, *a + *b);
}
